package com.mustafaiev.tair.cts.service;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mustafaiev.tair.cts.dto.GroupDTO;
import com.mustafaiev.tair.cts.exeption.DataNotStoredException;
import com.mustafaiev.tair.cts.facade.IGroupFacade;
import com.mustafaiev.tair.cts.factory.CostTrackingSystemFacadeFactory;

@Service
public class GroupService {

	private static final Logger LOGGER = Logger.getLogger(PayerService.class);

	@Autowired
	private CostTrackingSystemFacadeFactory costTrackingSystemFacadeFactory;

	@Autowired
	private EmailSendService emailSendService;

	public void registerGroup(final GroupDTO group) {
		try {
			getFacade().saveGroup(group);
		} catch (final DataNotStoredException e) {
			LOGGER.error(e.getLocalizedMessage(), e);
		}
	}

	private IGroupFacade getFacade() {
		final IGroupFacade facade = this.costTrackingSystemFacadeFactory
				.getFacade(IGroupFacade.class);
		return facade;
	}

}
